import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-09-03
 * Time: 13:48
 */
public class Test {
    public static void main(String[] args) {
        //完成猜数字游戏
        Scanner in = new Scanner(System.in);
        Random random = new Random();
        int ranDom = random.nextInt(100)+1;
        while(true) {
            System.out.println("请输入数字：");
            int n = in.nextInt();
            if(n > ranDom) {
                System.out.println("猜大了");
            }else if(n < ranDom) {
                System.out.println("猜小了");
            }else {
                System.out.println("恭喜你，猜对了。");
                break;
            }
        }

    }
    public static void main2(String[] args) {
        //获取一个数二进制序列中所有的偶数位和奇数位，分别输出二进制序列
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()) {
            int n = in.nextInt();

            for (int i = 1; i < 32; i+=2) {
                System.out.print(((n>>>i)&1)+ " ");
            }
            System.out.println();
            for (int i = 0; i < 31; i+=2) {
                System.out.print(((n >>> i) & 1) + " ");
            }
        }
    }
    public static void main1(String[] args) {
        //写一个函数返回参数二进制中 1 的个数比如：
        // 15       0000 1111       4 个 1
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()) {
            int n = in.nextInt();
            int count = 0;
            while(n != 0) {
                n &= (n-1);
                count++;
            }
            System.out.println(count);
        }
    }
}
